<template>
  <div>
    <PageTemplate>
      <div slot="content">
        <PageEditCollapse :is-search="false" :default-collapse="true">
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 200px;">{{$t('cm.baseinfo')}}</div>
          </div>
          <div>
            <!-- 表单 -->
            <el-form
              :model="meeting"
              label-position="right"
              label-width="150px"
              class="page-edit-colllapse-form"
              :rules="rules"
              ref="meeting"
            >
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_trial')" prop="trial">
                    <el-input v-model="meeting.trial"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_trial_region')" prop="trialRegion">
                    <el-input v-model="meeting.trialRegion"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_system_code')" prop="systemCode">
                    <el-input v-model="meeting.systemCode"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_teamName')" prop="teamName">
                    <el-input v-model="meeting.teamName"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_meetingStartTime')" prop="meetingStartTime">
                    <el-date-picker v-model="meeting.meetingStartTime" type="datetime" placeholder="选择日期" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_meetingEndTime')" prop="meetingEndTime">
                    <el-date-picker v-model="meeting.meetingEndTime" type="datetime" placeholder="选择日期" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_leadingUserName')" prop="leadingUserName">
                    <el-input v-model="meeting.leadingUserName"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_teamSafetyUserName')" prop="teamSafetyUserName">
                    <el-input v-model="meeting.teamSafetyUserName"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="20">
                  <el-form-item :label="$t('she.meeting_meetingUserName')" prop="participantName">
                    <el-input v-model="meetingUsers.participantName">
                        <el-button slot="append" icon="el-icon-search" @click="selectMeetingUser"></el-button>
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item :label="$t('she.meeting_sms_notice')" prop="smsNotice">
                    <el-radio v-model="meeting.smsNotice" label="1">是</el-radio>
                    <el-radio v-model="meeting.smsNotice" label="0">否</el-radio>
                  </el-form-item>
                </el-col>

              </el-row>
            </el-form>
          </div>
        </PageEditCollapse>
        <el-row class="row-empty-10"></el-row>
        <el-row>
          <el-button type="primary" @click="submitForm('meeting')">{{$t('cm.commit')}}</el-button>
          <el-button type="primary" @click="toList">{{$t('cm.return')}}</el-button>
        </el-row>
        <div style="height: 500px; width: 100%"></div>
      </div>
    </PageTemplate>
  </div>
</template>

<script>
import { ALERT } from '@/utils/responseHandle'
import * as Constant from '@/utils/constant'
import PageTemplate from '@/components/common/PageTemplate'
import PageEditCollapse from '@/components/common/PageEditCollapse'
import HasBtn from '@/mixins/HasBtn'
import { mapState } from 'vuex'
import { COMMON } from '@/utils/commonUtil'
import api_she from '@/api/api_she'
export default {
  components: {
    PageTemplate, PageEditCollapse
  },
  data () {
    return {
      meeting: {
        id: null,
        trial: null,
        trialRegion: null,
        systemCode: null,
        teamName: null,
        meetingStartTime: null,
        meetingEndTime: null,
        leadingUser: 11,
        leadingUserName: null,
        teamSafetyUser: 11,
        teamSafetyUserName: null,
        smsNotice: null
      },
      meetingUsers:{participantId:null, participantName:null},
      rules: {
        trial: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        trialRegion: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        systemCode: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        teamName: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        meetingStartTime: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        meetingEndTime: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        leadingUserName: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        teamSafetyUserName: [
          { required: true, message: '必填项', trigger: 'blur' }
        ],
        participantName: [
            { required: true, message: '必填项', trigger: 'blur' }
        ],
        smsNotice: [
          { required: true, message: '必填项', trigger: 'blur' }
        ]
      },
    }
  },
  created () {
    if (this.$router.history.current.params.id !== Constant.NEW_PARAMS) {
      this.sheMeetingGet(this.$router.history.current.params.id)
    }
  },
  methods: {
    sheMeetingGet (id) {
      api_she.sheMeetingGet({ id }, result => {
        if (result.code === Constant.RT_SUCCESS) {
          this.meeting = result.data.meeting
        } else {
          // _this.$t('cm.tips')
          ALERT.error(result.msg)
        }
      })
    },
    submitForm (formName) {
      this.$refs[formName].validate((valid, error) => {
        if (valid) {
          this.meeting.hseMeetingUserList = []
          let d = [this.meeting];
          api_she.sheMeetingSave(d, result => {
            if (result.code === Constant.RT_SUCCESS) {
              ALERT.success(result.msg)
              this.toList()
            } else {
              // _this.$t('cm.tips')
              ALERT.error(result.msg)
            }
          })
        } else {
          return false
        }
      })
    },
    toList () {
      COMMON.routerTo(Constant.ROUTE_SHE_MEETING.index, this.$router)
    },
    selectMeetingUser() {}
  },
  mounted () {
  },
  computed: {
  }
}
</script>

<style lang="scss">
</style>
